function UserUsAssTempLd(){
	this.form=this.InitForm();
	this.tab=this.InitEleUI();
	this.table=this.InitTable();
	
	$("#year").val($("#hidyear").val());
	this.form.render('select');
	
	this.InitGrid();
	
	this.currenttabindex=0;
}


UserUsAssTempLd.prototype.InitGrid=function (){
    var table;
    var _this=this;
    layui.use('table', function() {
        table = layui.table;
        table.init('subpayorglist', {
            height : $(window).height() - 100
            ,url : 'get_subsidyList_org_list' // 数据接口
            ,page : true // 开启分页
            ,limit : 30
            ,id: 'subpayorg'
            ,method:"post"
            ,request:{
                type:'post'
            }
            ,where:{
                year: $("#year").val(),
                mouth:$("#month").val(),
                orgid:$("#szdw").val()
            }
            ,done: function(res, page, count){
                var year = $("#year").val();
                var month = $("#month").val();
                var orgname =$("#szdw").text();
                $("#title").html(orgname+" "+year+" 年  "+month+" 保留津贴表");
            }
        });
    })
    return table;
}

UserUsAssTempLd.prototype.InitTable = function() {
    var table;
    var _this=this;
    layui.use('table', function() {
        table = layui.table;
        table.init('subpaylist', {
            height : $(window).height() - 100
            ,url : 'get_subsidyList_list' // 数据接口
            ,page : true // 开启分页
            ,limit : 30
            ,id: 'subpay'
            ,method:"post"
            ,request:{
                type:'post'
            }
            ,where:{
                year: $("#year").val(),
                mouth:$("#month").val(),
                orgid:$("#szdw").val()
            }
            ,done: function(res, page, count){
                var year = $("#year").val();
                var month = $("#month").val();
                var orgname =$("#szdw").text();
                $("#title").html(orgname+" "+year+" 年  "+month+" 保留津贴表");
            }
        });
    })
    return table;
}

UserUsAssTempLd.prototype.ChangeTab=function(index,year,quarter,userid){
	this.tab.tabChange('tabcontent', index);
	vSubPayListTempLd.InitIfream(year,quarter,userid)
}

UserUsAssTempLd.prototype.InitForm=function(){
	var form;
	layui.use('form', function(){
       form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
       form.on('select(year)', function (data) { 
    	   vSubPayListTempLd.InItPage();
       });
       form.on('select(month)', function(data){
    	   vSubPayListTempLd.InItPage();
       })
        form.on('select(szdw)', function(data){
            vSubPayListTempLd.InItPage();
        })
	   form.render();
	});  
	return form;
}

UserUsAssTempLd.prototype.InitEleUI=function(){
	var element;
	var _this=this;
	layui.use('element', function(){
       element=layui.element;
       
       element.on('tab(tabcontent)', function(data){
    	  vSubPayListTempLd.currenttabindex=data.index;
    	  if(data.index==1){
    		  _this.searchtable();
    	  }
	   }); 
	})
	return element;
}


UserUsAssTempLd.prototype.InItPage=function(){
	if(vSubPayListTempLd.currenttabindex==0){
		vSubPayListTempLd.searchlist();
	}
	else if(vSubPayListTempLd.currenttabindex==1){
		vSubPayListTempLd.searchtable();
	}
}

UserUsAssTempLd.prototype.result=function(result,msg){
	if(result>0){
		top.mylayui.msg('操作成功', {icon: 1});
		top.mylayui.closeAll('iframe');
		vSubPayListTempLd.searchtable();
	}
	else{
		if(msg){
			top.mylayui.msg(msg, {icon: 0});
		}else{
			top.mylayui.msg('操作失败', {icon: 0});
		}
	}
}

UserUsAssTempLd.prototype.searchtable=function(){
    var year=$("#year").val();
    var month=$("#month").val();
    var orgid = $("#szdw").val();
	this.table.reload('ldlist', { 
		  page: {
	        curr: 1 //重新从第 1 页开始
	      }
	    ,where: {  
	    	year:year,
            month:month,
            orgid:orgid
	    }  
	}); 
}

UserUsAssTempLd.prototype.searchlist = function () {
	var year=$("#year").val();
	var month=$("#month").val();
	var orgid = $("#szdw").val();
    this.grid.setOptions({
        newPage: 1, parms: {
            Method: "",
            year: year,month:month,orgid:orgid
        }
    });
    this.grid.loadData();
}

var vSubPayListTempLd=null;
$(function(){
	vSubPayListTempLd=new UserUsAssTempLd();
})